#ifndef TRANSFORMTOOL_H
#define TRANSFORMTOOL_H

#include <vector>
#include <iostream>
#include "tool.h"
#include "vector3.h"
#include "rendermanager.h"
#include "globalstates.h"
#include "voxel.h"

using namespace std;

class TransformTool : virtual public Tool
{
    enum MODE {NO_MODE = 0, TRANSLATE = 1, SCALE = 2, ROTATE = 3};

    RenderManager* rend;
    GlobalStates* global;

    set< vector3<int> > initialSelection;
    set< vector3<int> > newSelection;
    vector3<int> startCoords;
    vector3<int> currentCoords;
    vector3<int> drawCoords;
    vector3<int> difference;
    vector3<int> axisConstraint;
    bool mouseDown;
    MODE mode;
    float scaleConstant;

    TransformTool();

public:

    static TransformTool* getInstance();
    virtual string getType();
    void display();
    Result mousePressEvent(QMouseEvent *event);
    Result mouseReleaseEvent(QMouseEvent *event);
    Result mouseMoveEvent(QMouseEvent *event);
    Result keyPressEvent(QKeyEvent *event);
    Result keyReleaseEvent(QKeyEvent *event);
    void toggleScaleMode();
	void toggleTranslateMode();

private:

    vector3<int> findSelectionCentre();
    void drawScaledVoxel(vector3<int> v, int k, vector3<int> centre);
	void confirmTranslate();
    void confirmScale();
};

#endif // TRANSFORMTOOL_H
